package cn.ryh.filter.interfaceiml;

import javax.servlet.*;
import java.io.IOException;

/**
 * @ClassName InterfaceFilter
 * @Description 通过实现ServletContextInitializer接口，重写其onStartup()方法来注册Filter
 * @Author RaoYH
 */
public class InterfaceFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("InterfaceFilter过滤器初始化");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
            throws IOException, ServletException {
        System.out.println("InterfaceFilter过滤器执行过滤操作");

        filterChain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void destroy() {

        System.out.println("InterfaceFilter过滤器销毁");
    }
}
